package planit.controller.impl;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import planit.model.Model;
import planit.view.AddPersonToGroupDialog;

@SuppressWarnings("serial")
public class RemovePersonFromGroupController extends AbstractAction {

	private Model model;

	public RemovePersonFromGroupController(Model model) {
		this.model = model;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		AddPersonToGroupDialog dialog = (AddPersonToGroupDialog) this
				.getValue("RemovePersonFromGroupDialog");
		
		int gId = dialog.getGroupId();
		int pId = dialog.getPersonInGroupId();

		model.getSchedule().getGroup(gId).removePerson(
				model.getSchedule().getPerson(pId));
		dialog.updateGroupPersonsList();

	}

}
